package mint.modules.symbol;

import java.util.Formatter;
import java.util.HashMap;

import mint.modules.type.Type;

public class SymbolTable {
	private HashMap<String, Symbol> table;
	
	public SymbolTable()
	{
		table = new HashMap<String, Symbol>();
		table.put(Type.stringName, ClassSymbol.stringSymbol);
	}
	
	public Symbol getSymbol(String name)
	{
		if (table.containsKey(name))
			return table.get(name);
		else
			return null;
	}
	
	public int getSize()
	{
		return table.size();
	}
	
	public boolean addSymbol(Symbol symbol)
	{
		if (table.get(symbol.getName()) == null )
		{
			table.put(symbol.getName(), symbol);
			return true;
		} else
			return false;
	}
	
	public void printTable(Formatter output, int tabSize)
	{
		for(Symbol symbol : table.values())
		{
			symbol.print(output, tabSize);
		}
	}
}
